package h.c.z.designPattern.C02_SingletonPattern;

/**
 * 单例模式-饿汉  静态属性、静态代码块 [可用]
 * @author jinsicao
 */
public class Singleton_01 {

	private static Singleton_01 instance = new Singleton_01();
	
	private static int i = 0;
	
	private static int j = 0;
	
	// 饿汉式（静态代码块）[可用]
//	private static Singleton_01 instance;
//	
//	static {
//		instance = new Singleton_01();
//	}
	
	private Singleton_01() {
		System.out.println("Singleton_01#" + i++);
	}
	
	public static Singleton_01 getInstance() {
		System.out.println("Singleton_01->getInstance#" + j++);
		return instance;
	}
	
	@SuppressWarnings("unused")
	public static void main(String[] args) {
		Singleton_01 singleton = Singleton_01.getInstance();
	}
}
